package com.pro.common.api.model;

import com.pro.common.api.exception.BusinessException;

public interface IResponseStr<T> extends IResponse<T, String> {
    // http异常 直接抛出异常 如果外层允许中断全部任务 则会全部中断 避免无效请求.
    // http正常时,可能接口内容还会额外的有业务错误码
    default void failThrow() {
        if (!isSuccess()) {
            String code = getCode();
            if ("401".equals(code)) {
                throwUnAuthorization();
            } else {
                throw new BusinessException(code, getMsg());
            }
        }
    }
}
